package com.study.sbsummary.utils;

import com.yidian.serving.index.metrics.Metrics;
import com.yidian.serving.index.metrics.common.Tag;

public class MetricUtils {

    /**
     * 消耗时间打点
     *
     * @param reqBegin
     */
    public static void metricLatency(String business,String tagName ,String tagValue, long reqBegin) {
        Metrics.tag(business, Tag.newTag(tagName, tagValue)).latency(System.currentTimeMillis() - reqBegin);
    }

    /**
     * 节点qps打点
     *
     */
    public static void metricQps(String business,String tagName ,String tagValue) {
        Metrics.tag(business, Tag.newTag(tagName, tagValue)).qps();
    }

    /**
     * 事件发生失败概率打点
     *
     * @param groupId
     * @param node
     * @param ratio
     */
    public static void metricMiniRatioFales(String groupId, String node, String ratio) {
        Metrics.tag(groupId, Tag.newTag("node", node)).ratio(ratio, false);
    }

    /**
     * 事件发生成功概率打点
     *
     * @param groupId
     * @param node
     * @param ratio
     */
    public static void metricMiniRatioTrue(String groupId, String node, String ratio) {
        Metrics.tag(groupId, Tag.newTag("node", node)).ratio(ratio, true);
    }
}
